# -*- Python -*-

import os
import platform
import subprocess

import lit
import lit.formats
import lit.util

### Helper Functions

def make_path(*args):
  return os.path.normpath(os.path.join(*args))

kIsWindows = platform.system() == 'Windows'

###

config.name = 'bloaty'

bloaty_src_root = getattr(config, 'bloaty_src_root', None)
if not bloaty_src_root:
  lit_config.fatal("missing 'bloaty_src_root' key in the site specific config")
bloaty_src_root = os.path.normpath(bloaty_src_root)

bloaty_obj_root = getattr(config, 'bloaty_obj_root', None)
if not bloaty_obj_root:
  lit_config.fatal("missing 'bloaty_obj_root' key in the site specific config")
bloaty_obj_root = os.path.normpath(bloaty_obj_root)

if not lit_config.params.get('bloaty', None):
  lit_config.fatal("missing parameter 'bloaty'")

lit_config.note('Using bloaty: {}'.format(lit_config.params['bloaty']))
lit_config.note('Using FileCheck: {}'.format(config.filecheck_path))
lit_config.note('Using yaml2obj: {}'.format(config.yaml2obj_path))

use_lit_shell = os.environ.get('LIT_USE_INTERNAL_SHELL', kIsWindows)
if not use_lit_shell:
  config.available_features.add('shell')

config.test_format = lit.formats.ShTest(execute_external = False)

config.suffixes = ['.test']
config.excludes = ['testdata']

config.test_source_root = os.path.join(bloaty_src_root, 'tests')
config.test_exec_root = os.path.join(bloaty_obj_root, 'tests')

config.substitutions.append(('%FileCheck', config.filecheck_path))
config.substitutions.append(('%yaml2obj', config.yaml2obj_path))
config.substitutions.append(('%bloaty', lit_config.params['bloaty']))
